//
//  SINATeacherSettingViewController.m
//  sinashebao
//
//  Created by  androidlongs on 2017/12/29.
//  Copyright © 2017年  androidlongs. All rights reserved.
//

#import "SINATeacherSettingViewController.h"
#import "SINAUserModel.h"
#import "SINAStudentCountSafeViewController.h"
#import "SINALoginViewController.h"
#import "SINANavLoginViewController.h"
#import "SINAAboutMeViewController.h"
#import "SINATeacherSelectIdentsViewController.h"
#import "JPUSHService.h"

@interface SINATeacherSettingViewController ()
@property (weak, nonatomic) IBOutlet UIScrollView *scrollview;
@property (weak, nonatomic) IBOutlet UIView *itemView1;
//退出登录
@property (weak, nonatomic) IBOutlet UILabel *exitLogin;
//帐号安全
@property (weak, nonatomic) IBOutlet UIView *countSafeView;
//清除缓存
@property (weak, nonatomic) IBOutlet UIView *clearView;
//转换身份
@property (weak, nonatomic) IBOutlet UIView *selectIdentView;

//关于肆迹
@property (weak, nonatomic) IBOutlet UIView *aboutMe;

@end

@implementation SINATeacherSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title=@"设置";
    
    //退出登录点击事件
    UITapGestureRecognizer *exitTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(exitClickFunction)];
    [self.exitLogin addGestureRecognizer:exitTapGestureRecognizer];
    self.exitLogin.userInteractionEnabled = YES;
    
    //关于肆迹点击事件
    UITapGestureRecognizer *aboutMeRecognizer =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(aboutMeClickFunction)];
    [self.aboutMe addGestureRecognizer:aboutMeRecognizer];
    self.aboutMe.userInteractionEnabled = YES;
    
    
    //清除
    UITapGestureRecognizer *clearRecognizer =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clearCountClickFunction)];
    [self.clearView addGestureRecognizer:clearRecognizer];
    self.clearView.userInteractionEnabled = YES;
    
    //账号安全
    UITapGestureRecognizer *safeRecognizer =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(countSafeClickFunction)];
    [self.countSafeView addGestureRecognizer:safeRecognizer];
    self.countSafeView.userInteractionEnabled = YES;
    
    //转换身份
    UITapGestureRecognizer *selectRecognizer =[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectIdentClickFunction)];
    [self.selectIdentView addGestureRecognizer:selectRecognizer];
    self.selectIdentView.userInteractionEnabled = YES;
    
    self.scrollview.contentSize=CGSizeMake(mainW, mainH+1);
}
//账号安全
-(void)countSafeClickFunction{
    SINAStudentCountSafeViewController *controll=[[SINAStudentCountSafeViewController alloc]init];
    [self.navigationController pushViewController:controll animated:YES];
}
//退出登录
-(void)exitClickFunction{
    
    WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:@"确定退出登录?" sureBtn:@"确定"
                                                         cancleBtn:@"取消"];
    __weak typeof(self) weakSelf = self;
    alertView.resultIndex = ^(NSInteger index) {
        
        //移除推送
        [JPUSHService setAlias:@"123" completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
            DLog(@"别名注册完成 seq %ld and iResCode %ld",(long)iResCode,seq);
        } seq:102];
        //清除用户信息
        [[SINACommonUserHelper share] clearUserModel];
        //登录页面
        SINALoginViewController *rootViewControll = [[SINALoginViewController alloc]init ];
        SINANavLoginViewController *homeController = [[SINANavLoginViewController alloc] initWithRootViewController:rootViewControll];
        weakSelf.view.window.rootViewController = homeController;
        [weakSelf.view.window makeKeyAndVisible];
    };
    [alertView showXLAlertView];
}


//清除缓存
-(void)clearCountClickFunction{
    NSString *message =@"已清除缓存 10 M";
    WISAlertView *alertView =   [[WISAlertView alloc]initWithTitle:@"提示" message:message sureBtn:@"确定"
                                                         cancleBtn:nil];
    [alertView showXLAlertView];
}
////关于肆迹
-(void)aboutMeClickFunction{
    SINAAboutMeViewController *aboutMeController = [[SINAAboutMeViewController alloc]initWithNibName:@"SINAAboutMeViewController" bundle:nil];
    [self.navigationController pushViewController:aboutMeController animated:YES];
}
//选择身份
-(void)selectIdentClickFunction{
    SINATeacherSelectIdentsViewController *aboutMeController = [[SINATeacherSelectIdentsViewController alloc]initWithNibName:@"SINATeacherSelectIdentsViewController" bundle:nil];
    [self.navigationController pushViewController:aboutMeController animated:YES];
}
-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
